<template>
  <div class="login">
    <img style="width: 100vw; height: 100vh; object-fit: cover" src="../../assets/b1.jpg" alt="">
    <div class="right-login">
      <div class="login-nav">
        <img src="@/assets/img.png" alt=""/>
        <div class="navTitle">
          <h1 style="font-weight: 800">草莓卷</h1>
          <p style="margin-top: 2px">Strawberry roll</p>
        </div>
      </div>
      <!--字体-->
      <div class="login-title">
        <div style="font-size: 18px">WELCOME !</div>
        <div style="font-size: 16px; margin-top: 2px;">草莓卷智能客服</div>
      </div>

      <!--二维码登录-->
      <div class="login-qrCode">
        <h2>手机号登陆</h2>
        <div>
          <el-form ref="formEl" :model="form" :rules="data.rules">
            <el-form-item prop="phone">
              <el-input
                size="large"
                v-model="form.phone"
                placeholder="请输入账号"
              >
                <template #prefix>
                  <div class="input-ico">
                    <el-icon color="#909399" class="no-inherit">
                      <UserFilled />
                    </el-icon>
                  </div>
                </template>
              </el-input>
            </el-form-item>
            <el-form-item prop="password">
              <el-input
                size="large"
                v-model="form.password"
                show-password
                placeholder="默认密码为手机号"
              >
                <template #prefix>
                  <div class="input-ico">
                    <el-icon color="#909399" class="no-inherit">
                      <Lock />
                    </el-icon>
                  </div>
                </template>
              </el-input>
            </el-form-item>
          </el-form>
          <div class="subFrom">
            <el-button class="button" size="large" type="primary" :loading="form.loadLoading" round
                       @click="Fu_loginByPass()">登陆
            </el-button>
          </div>
          <div class="forgetPassword">
            <el-button type="primary" link style="color: black; font-size: 12px">
              <span style="font-size: 12px">忘记密码？</span>
            </el-button>
          </div>
        </div>
      </div>

      <div class="officialWebsite">
        <a style="color: #0099ff; font-size:12px" href="https://www.inwuoo.com/" target="_blank"
        >还没有账户，去官网联系我们 》</a
        >
      </div>
      <div class="support">
        <p>
          <img
            src="http://client.cdn.inwuoo.com/image/2022/04/19/fa764dba-ee49-4ba5-9ec9-ec087397e9f5_165034760537348.png"
            alt=""
          />
        </p>
        <p>阿里云提供云服务支持</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import {reactive, onMounted, ref} from "vue";
import {useRouter} from 'vue-router'
import {useStore} from "vuex"
const router = useRouter()
const formEl = ref()
const store = useStore()
const form = reactive({
  phone: "",
  password: "",
  authCode: "",
  loadLoading: false,
  checkCompanyFlag: 0,
  checkCompanyName: ''
})
onMounted(() => {
  store.dispatch("user/login").then(res => {
    router.push("/chat")
  })
})
const data = reactive({
  companyList: [],
  rules: {
    phone: [
      {required: true, message: '请输入账号', trigger: 'blur'}
    ],
    password: [
      {required: true, message: '请输入密码', trigger: 'blur'}
    ]
  }
})
const Fu_loginByPass = () => {
  store.dispatch("message/newNotice")

  formEl.value.validate(valid => {
    if(valid) {
      router.push("/chat")
    }
  })
}
</script>

<style scoped lang="scss">
.login {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  video {
    width: 100%;
    height: 100%;
  }

  .right-login {
    width: 500px;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 0 36px;
    .login-title{
      margin-top: 30px;
      font-weight: bold;
    }
    .login-nav {
      margin-top: 36px;
      display: flex;
      align-items: center;
      img {
        width: 40px;
        height: 40px;
        object-fit: contain;
      }
      .navTitle{
        margin-left: 10px;
        h1 {
          font-weight: 900;
          font-size: 18px;
          margin: 0;
        }
        p{
          font-size: 16px;
          margin: 0;

        }
      }
    }

    .login-qrCode, .company-select {
      width: 100%;
      height: 453px;
      background: #fff;
      padding: 40px 40px 0;
      box-shadow: 0 4px 8px rgba(31, 35, 41, .03), 0 3px 6px -6px rgba(31, 35, 41, .05), 0 6px 18px 6px rgba(31, 35, 41, .03%);
      margin-top: 50px;
      border: 1px solid #dee0e3;
      position: relative;
      font-size: 12px;
      position: relative;

      h2 {
        font-size: 16px;
        color: #0099ff;
        text-align: center;
        margin: 30px 0;
      }

      .input-ico {
        padding: 0 10px;
        height: 100%;
        margin-left: 1px;
        background: #F5F7FA;
        position: relative;
        left: -15px;
        border-radius: 3px 0 0 3px;

        .no-inherit {
          position: relative;
          top: 1px;
        }
      }

      .subFrom {
        text-align: center;
        margin-top: 50px;

        .button {
          width: 100%;
        }
      }

      .forgetPassword {
        position: absolute;
        bottom: 10px;
        right: 0;
        transform: translateX(-50%);

        span:hover {
          cursor: pointer;
          text-decoration: underline;
        }
      }
    }

    .company-select {
      .com-check-view {
        text-align: center;
        margin-top: 50px;
        position: relative;

        .el-select {
          width: 250px !important;
          padding-left: 20px !important;
        }

        .subFrom {
          text-align: center;
          margin-top: 50px;

          .button {
            width: 100%;
          }
        }

      }
    }

    .officialWebsite {
      margin-top: 50px;
      color: #0099ff;
      text-align: center;

      a {
        font-size: 12px;
      }

      a:hover {
        text-decoration: underline;
      }
    }

    .support {
      margin-top: 130px;
      text-align: center;

      p {
        line-height: 50px;
        font-size: 12px;

        img {
          width: 101px;
          height: 23px;
          margin: 0 auto;
        }
      }
    }
  }
}
</style>
